package demo4;
//继承与组合
class Battery {
    private int barrery;

    public Battery(int barrery){
        this.barrery = barrery;
    }
    public void retBarrery(){
        System.out.println("电量为：" + barrery);
    }
}


class Brand {
    private String brand;
    private Battery battery;

    public Brand(String brand, Battery battery) {
        this.brand = brand;
        this.battery = battery;
    }

    public void phoneApply(){
        System.out.println(brand + "手机开机");
        battery.retBarrery();
    }
}
public class Test2 {
    public static void main(String[] args) {
        Battery battery = new Battery(5000);

        Brand brand = new Brand("apply",battery);

        brand.phoneApply();
    }
}
